import request from "@/utils/request";

//请求前缀
const api_prefix = "/machine";

export function saveMachine(data) {
  return request({
    //模板字符串拼接参数
    url: `${api_prefix}/save`,
    method: "POST",
    data: data,
  });
}

export function queryWithMachineId(pageNo, pageSize, machineId) {
  return request({
    //模板字符串拼接参数
    url: `${api_prefix}/query/${pageNo}/${pageSize}`,
    method: "GET",
    params: {
      machineId: machineId,
    },
  });
}

export function queryWithLocation(pageNo, pageSize, location) {
  return request({
    //模板字符串拼接参数
    url: `${api_prefix}/query/like/${pageNo}/${pageSize}`,
    method: "GET",
    params: {
      location: location,
    },
  });
}

export function removeMachine(id) {
  return request({
    //模板字符串拼接参数
    url: `${api_prefix}/delete/${id}`,
    method: "DELETE"
  });
}

export function findMachineEcho(id) {
  return request({
    //模板字符串拼接参数
    url: `${api_prefix}/echo/${id}`,
    method: "GET",
  });
}

export function updateMachine(data) {
  return request({
    //模板字符串拼接参数
    url: `${api_prefix}/update`,
    method: "POST",
    data: data,
  });
}

//第五种：param多个参数请求
// export function list(username, password) {
//   return request({
//     //模板字符串拼接参数
//     url: `${api_prefix}/list`,
//     method: "GET",
//     params: {
//       username: username,
//       password: password,
//     },
//   });
// }
